home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Technology Seed / Jan. '98 ATS.toast / QuickTime™ 3.0b11 / QTPublicInterfaces / CIncludes / OSUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-12  |  10.7 KB  |  434 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        OSUtils.h
  3.  
  4.      Contains:    OS Utilities Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0 Beta
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __OSUTILS__
  19. #define __OSUTILS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. /*  HandToHand and other memory utilties were moved to MacMemory.h */
  28. #ifndef __MACMEMORY__
  29. #include <MacMemory.h>
  30. #endif
  31. /*  GetTrapAddress and other trap table utilties were moved to Patches.h */
  32. #ifndef __PATCHES__
  33. #include <Patches.h>
  34. #endif
  35. /*  Date and Time utilties were moved to DateTimeUtils.h */
  36. #ifndef __DATETIMEUTILS__
  37. #include <DateTimeUtils.h>
  38. #endif
  39.  
  40.  
  41.  
  42. #if PRAGMA_ONCE
  43. #pragma once
  44. #endif
  45.  
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49.  
  50. #if PRAGMA_IMPORT
  51. #pragma import on
  52. #endif
  53.  
  54. #if PRAGMA_STRUCT_ALIGN
  55.     #pragma options align=mac68k
  56. #elif PRAGMA_STRUCT_PACKPUSH
  57.     #pragma pack(push, 2)
  58. #elif PRAGMA_STRUCT_PACK
  59.     #pragma pack(2)
  60. #endif
  61.  
  62.  
  63. enum {
  64.     useFree                        = 0,
  65.     useATalk                    = 1,
  66.     useAsync                    = 2,
  67.     useExtClk                    = 3,                            /*Externally clocked*/
  68.     useMIDI                        = 4
  69. };
  70.  
  71.  
  72. enum {
  73.     false32b                    = 0,                            /*24 bit addressing error*/
  74.     true32b                        = 1                                /*32 bit addressing error*/
  75. };
  76.  
  77.  
  78. enum {
  79.                                                                 /* result types for RelString Call */
  80.     sortsBefore                    = -1,                            /*first string < second string*/
  81.     sortsEqual                    = 0,                            /*first string = second string*/
  82.     sortsAfter                    = 1                                /*first string > second string*/
  83. };
  84.  
  85.  
  86. enum {
  87.     dummyType                    = 0,
  88.     vType                        = 1,
  89.     ioQType                        = 2,
  90.     drvQType                    = 3,
  91.     evType                        = 4,
  92.     fsQType                        = 5,
  93.     sIQType                        = 6,
  94.     dtQType                        = 7,
  95.     nmType                        = 8
  96. };
  97.  
  98. typedef SignedByte                         QTypes;
  99.  
  100. struct SysParmType {
  101.     UInt8                             valid;
  102.     UInt8                             aTalkA;
  103.     UInt8                             aTalkB;
  104.     UInt8                             config;
  105.     short                             portA;
  106.     short                             portB;
  107.     long                             alarm;
  108.     short                             font;
  109.     short                             kbdPrint;
  110.     short                             volClik;
  111.     short                             misc;
  112. };
  113. typedef struct SysParmType                SysParmType;
  114.  
  115. typedef SysParmType *                    SysPPtr;
  116.  
  117. struct QElem {
  118.     struct QElem *                    qLink;
  119.     short                             qType;
  120.     short                             qData[1];
  121. };
  122. typedef struct QElem                    QElem;
  123. typedef QElem *                            QElemPtr;
  124. #if TARGET_OS_MAC
  125.  
  126. struct QHdr {
  127.     short                             qFlags;
  128.     QElemPtr                         qHead;
  129.     QElemPtr                         qTail;
  130. };
  131. typedef struct QHdr                        QHdr;
  132. #else
  133. /*
  134.    this version of QHdr contains the Mutex necessary for
  135.    non-mac non-interrupt code
  136. */
  137.  
  138. struct QHdr {
  139.     short                             qFlags;
  140.     short                             pad;
  141.     long                             MutexID;
  142.     QElemPtr                         qHead;
  143.     QElemPtr                         qTail;
  144. };
  145. typedef struct QHdr                        QHdr;
  146. #endif  /* TARGET_OS_MAC */
  147.  
  148. typedef QHdr *                            QHdrPtr;
  149.  
  150.  
  151. typedef CALLBACK_API( void , DeferredTaskProcPtr )(long dtParam);
  152. /*
  153.     WARNING: DeferredTaskProcPtr uses register based parameters under classic 68k
  154.              and cannot be written in a high-level language without 
  155.              the help of mixed mode or assembly glue.
  156. */
  157. typedef REGISTER_UPP_TYPE(DeferredTaskProcPtr)                     DeferredTaskUPP;
  158. enum { uppDeferredTaskProcInfo = 0x0000B802 };                     /* register no_return_value Func(4_bytes:A1) */
  159. #define NewDeferredTaskProc(userRoutine)                         (DeferredTaskUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeferredTaskProcInfo, GetCurrentArchitecture())
  160. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  161.     #pragma parameter CallDeferredTaskProc(__A0, __A1)
  162.     void CallDeferredTaskProc(DeferredTaskUPP routine, long dtParam) = 0x4E90;
  163. #else
  164.     #define CallDeferredTaskProc(userRoutine, dtParam)             CALL_ONE_PARAMETER_UPP((userRoutine), uppDeferredTaskProcInfo, (dtParam))
  165. #endif
  166.  
  167. struct DeferredTask {
  168.     QElemPtr                         qLink;
  169.     short                             qType;
  170.     short                             dtFlags;
  171.     DeferredTaskUPP                 dtAddr;
  172.     long                             dtParam;
  173.     long                             dtReserved;
  174. };
  175. typedef struct DeferredTask                DeferredTask;
  176. typedef DeferredTask *                    DeferredTaskPtr;
  177.  
  178. #if PRAGMA_STRUCT_ALIGN
  179.     #pragma options align=mac68k
  180. #elif PRAGMA_STRUCT_PACKPUSH
  181.     #pragma pack(push, 1)
  182. #elif PRAGMA_STRUCT_PACK
  183.     #pragma pack(1)
  184. #endif
  185.  
  186.  
  187. struct MachineLocation {
  188.     Fract                             latitude;
  189.     Fract                             longitude;
  190.     union {
  191.         SInt8                             dlsDelta;                /* signed byte; daylight savings delta */
  192.         long                             gmtDelta;                /* use low 24-bits only */
  193.     }                                 u;
  194. };
  195. typedef struct MachineLocation            MachineLocation;
  196.  
  197. #if PRAGMA_STRUCT_ALIGN
  198.     #pragma options align=reset
  199. #elif PRAGMA_STRUCT_PACKPUSH
  200.     #pragma pack(pop)
  201. #elif PRAGMA_STRUCT_PACK
  202.     #pragma pack(2)
  203. #endif
  204.  
  205.  
  206. EXTERN_API( Boolean )
  207. IsMetric                        (void)                                                        THREEWORDINLINE(0x3F3C, 0x0004, 0xA9ED);
  208.  
  209. EXTERN_API( SysPPtr )
  210. GetSysPPtr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x01F8);
  211.  
  212.  
  213. /*
  214.     NOTE: SysBeep() has been moved to Sound.h.  
  215.           We could not automatically #include Sound.h in this file
  216.           because Sound.h indirectly #include's OSUtils.h which
  217.           would make a circular include.
  218. */
  219.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  220.                                                                                             #pragma parameter __D0 DTInstall(__A0)
  221.                                                                                             #endif
  222. EXTERN_API( OSErr )
  223. DTInstall                        (DeferredTaskPtr         dtTaskPtr)                            ONEWORDINLINE(0xA082);
  224.  
  225.  
  226.  
  227. #if TARGET_CPU_PPC || !TARGET_OS_MAC
  228. #define GetMMUMode() ((SInt8)true32b)
  229. #define SwapMMUMode(x) (*(SInt8*)(x) = true32b)
  230. #else
  231. EXTERN_API( SInt8 )
  232. GetMMUMode                        (void)                                                        TWOWORDINLINE(0x1EB8, 0x0CB2);
  233.  
  234.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  235.                                                                                             #pragma parameter SwapMMUMode(__A0)
  236.                                                                                             #endif
  237. EXTERN_API( void )
  238. SwapMMUMode                        (SInt8 *                mode)                                THREEWORDINLINE(0x1010, 0xA05D, 0x1080);
  239.  
  240. #endif
  241.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  242.                                                                                             #pragma parameter Delay(__A0, __A1)
  243.                                                                                             #endif
  244. EXTERN_API( void )
  245. Delay                            (unsigned long             numTicks,
  246.                                  unsigned long *        finalTicks)                            TWOWORDINLINE(0xA03B, 0x2280);
  247.  
  248.  
  249. EXTERN_API( OSErr )
  250. WriteParam                        (void);
  251.  
  252.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  253.                                                                                             #pragma parameter Enqueue(__A0, __A1)
  254.                                                                                             #endif
  255. EXTERN_API( void )
  256. Enqueue                            (QElemPtr                 qElement,
  257.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96F);
  258.  
  259.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  260.                                                                                             #pragma parameter __D0 Dequeue(__A0, __A1)
  261.                                                                                             #endif
  262. EXTERN_API( OSErr )
  263. Dequeue                            (QElemPtr                 qElement,
  264.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96E);
  265.  
  266.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  267.                                                                                             #pragma parameter __D0 SetCurrentA5
  268.                                                                                             #endif
  269. EXTERN_API( long )
  270. SetCurrentA5                    (void)                                                        THREEWORDINLINE(0x200D, 0x2A78, 0x0904);
  271.  
  272.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  273.                                                                                             #pragma parameter __D0 SetA5(__D0)
  274.                                                                                             #endif
  275. EXTERN_API( long )
  276. SetA5                            (long                     newA5)                                ONEWORDINLINE(0xC18D);
  277.  
  278.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  279.                                                                                             #pragma parameter __D0 InitUtil
  280.                                                                                             #endif
  281. EXTERN_API( OSErr )
  282. InitUtil                        (void)                                                        ONEWORDINLINE(0xA03F);
  283.  
  284.  
  285. #if TARGET_CPU_PPC
  286. EXTERN_API( void )
  287. MakeDataExecutable                (void *                    baseAddress,
  288.                                  unsigned long             length);
  289.  
  290. #endif  /* TARGET_CPU_PPC */
  291.  
  292. #if TARGET_CPU_68K
  293. EXTERN_API( Boolean )
  294. SwapInstructionCache            (Boolean                 cacheEnable);
  295.  
  296. EXTERN_API( void )
  297. FlushInstructionCache            (void)                                                        TWOWORDINLINE(0x7001, 0xA098);
  298.  
  299. EXTERN_API( Boolean )
  300. SwapDataCache                    (Boolean                 cacheEnable);
  301.  
  302. EXTERN_API( void )
  303. FlushDataCache                    (void)                                                        TWOWORDINLINE(0x7003, 0xA098);
  304.  
  305. EXTERN_API( void )
  306. FlushCodeCache                    (void)                                                        ONEWORDINLINE(0xA0BD);
  307.  
  308.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  309.                                                                                             #pragma parameter __D0 FlushCodeCacheRange(__A0, __A1)
  310.                                                                                             #endif
  311. EXTERN_API( OSErr )
  312. FlushCodeCacheRange                (void *                    address,
  313.                                  unsigned long             count)                                TWOWORDINLINE(0x7009, 0xA098);
  314.  
  315. #endif  /* TARGET_CPU_68K */
  316.  
  317.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  318.                                                                                             #pragma parameter ReadLocation(__A0)
  319.                                                                                             #endif
  320. EXTERN_API( void )
  321. ReadLocation                    (MachineLocation *        loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA051);
  322.  
  323.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  324.                                                                                             #pragma parameter WriteLocation(__A0)
  325.                                                                                             #endif
  326. EXTERN_API( void )
  327. WriteLocation                    (const MachineLocation * loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA052);
  328.  
  329.  
  330.  
  331. #if OLDROUTINENAMES
  332. #define IUMetric() IsMetric()
  333. #endif  /* OLDROUTINENAMES */
  334.  
  335. /*
  336.     NOTE: SysEnvirons is obsolete.  You should be using Gestalt.
  337. */
  338. /* Environs Equates */
  339.  
  340. enum {
  341.     curSysEnvVers                = 2                                /*Updated to equal latest SysEnvirons version*/
  342. };
  343.  
  344.  
  345. struct SysEnvRec {
  346.     short                             environsVersion;
  347.     short                             machineType;
  348.     short                             systemVersion;
  349.     short                             processor;
  350.     Boolean                         hasFPU;
  351.     Boolean                         hasColorQD;
  352.     short                             keyBoardType;
  353.     short                             atDrvrVersNum;
  354.     short                             sysVRefNum;
  355. };
  356. typedef struct SysEnvRec                SysEnvRec;
  357.  
  358. enum {
  359.                                                                 /* Machine Types */
  360.     envMac                        = -1,
  361.     envXL                        = -2,
  362.     envMachUnknown                = 0,
  363.     env512KE                    = 1,
  364.     envMacPlus                    = 2,
  365.     envSE                        = 3,
  366.     envMacII                    = 4,
  367.     envMacIIx                    = 5,
  368.     envMacIIcx                    = 6,
  369.     envSE30                        = 7,
  370.     envPortable                    = 8,
  371.     envMacIIci                    = 9,
  372.     envMacIIfx                    = 11
  373. };
  374.  
  375.  
  376. enum {
  377.                                                                 /* CPU types */
  378.     envCPUUnknown                = 0,
  379.     env68000                    = 1,
  380.     env68010                    = 2,
  381.     env68020                    = 3,
  382.     env68030                    = 4,
  383.     env68040                    = 5
  384. };
  385.  
  386.  
  387. enum {
  388.                                                                 /* Keyboard types */
  389.     envUnknownKbd                = 0,
  390.     envMacKbd                    = 1,
  391.     envMacAndPad                = 2,
  392.     envMacPlusKbd                = 3,
  393.     envAExtendKbd                = 4,
  394.     envStandADBKbd                = 5,
  395.     envPrtblADBKbd                = 6,
  396.     envPrtblISOKbd                = 7,
  397.     envStdISOADBKbd                = 8,
  398.     envExtISOADBKbd                = 9
  399. };
  400.  
  401.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  402.                                                                                             #pragma parameter __D0 SysEnvirons(__D0, __A0)
  403.                                                                                             #endif
  404. EXTERN_API( OSErr )
  405. SysEnvirons                        (short                     versionRequested,
  406.                                  SysEnvRec *            theWorld)                            ONEWORDINLINE(0xA090);
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414. #if PRAGMA_STRUCT_ALIGN
  415.     #pragma options align=reset
  416. #elif PRAGMA_STRUCT_PACKPUSH
  417.     #pragma pack(pop)
  418. #elif PRAGMA_STRUCT_PACK
  419.     #pragma pack()
  420. #endif
  421.  
  422. #ifdef PRAGMA_IMPORT_OFF
  423. #pragma import off
  424. #elif PRAGMA_IMPORT
  425. #pragma import reset
  426. #endif
  427.  
  428. #ifdef __cplusplus
  429. }
  430. #endif
  431.  
  432. #endif /* __OSUTILS__ */
  433.  
  434.